using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using DataObject.Database;
using DataObject.Model;

	public partial class ContactMapper
	{
		#region ToSingle

		public static ContactDTO ToSingle(Contact entity)
		{
			if (entity == null)
			{
				return null;
			}
			return new ContactDTO
			{
				Active = entity.Active,
				CellPhone = entity.CellPhone,
				ContactID = entity.ContactID,
				ContactName = entity.ContactName,
				Email = entity.Email,
				Gender = entity.Gender,
				Phone = entity.Phone,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				WorkExtension = entity.WorkExtension,
			};
		}

		#endregion

		#region ToEntity

		public static Contact ToEntity(Contact entity, ContactDTO businessobject)
		{
			if (businessobject == null)
			{
				return null;
			}
			entity.Active = businessobject.Active;
			entity.CellPhone = businessobject.CellPhone;
			entity.ContactID = businessobject.ContactID;
			entity.ContactName = businessobject.ContactName;
			entity.Email = businessobject.Email;
			entity.Gender = businessobject.Gender;
			entity.Phone = businessobject.Phone;
			entity.ModifiedBy = businessobject.ModifiedBy;
			entity.ModifiedDate = businessobject.ModifiedDate;
			entity.WorkExtension = businessobject.WorkExtension;
			return entity;
		}

		#endregion

		#region ToBusinessObject

		public static ContactDTO ToBusinessObject(Contact entity)
		{
			if (entity == null)
			{
				return null;
			}
			return new ContactDTO
			{
				Active = entity.Active,
				CellPhone = entity.CellPhone,
				ContactID = entity.ContactID,
				ContactName = entity.ContactName,
				Email = entity.Email,
				Gender = entity.Gender,
				Phone = entity.Phone,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				WorkExtension = entity.WorkExtension,
			};
		}

		#endregion

		#region ToBusinessObjectHasChildren

		public static ContactDTO ToBusinessObjectHasChildren(Contact entity, params Type[] types)
		{
			if (entity == null)
			{
				return null;
			}
			ContactDTO businessobject = new ContactDTO
			{
				Active = entity.Active,
				CellPhone = entity.CellPhone,
				ContactID = entity.ContactID,
				ContactName = entity.ContactName,
				Email = entity.Email,
				Gender = entity.Gender,
				Phone = entity.Phone,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				WorkExtension = entity.WorkExtension,
			};
			if (types.Contains<Type>(typeof(ProviderContact)) || types.Length == 0)
			{
				businessobject.ProviderContactCollection = new List<ProviderContactDTO>();
				foreach(var item in entity.ProviderContacts)
				{
					businessobject.ProviderContactCollection.Add(ProviderContactMapper.ToBusinessObject(item));
				}
			}
			return businessobject;
		}

		#endregion

	}
